package com.vijay.controller;

import com.vijay.extension.common.Context;
import com.vijay.extension.service.Vehicle;
import com.vijay.extension.spring.service.SpringVehicle;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
public class HelloController implements InitializingBean {


    private final Vehicle vehicle;

    private final SpringVehicle springVehicle;


    @Override
    public void afterPropertiesSet() {
        System.out.println(vehicle.getClass());
        Context context = new Context();
        context.addParameter("carType", "boat");
        vehicle.run(context);
        System.out.println(vehicle.getClass());

        context = new Context();
        context.addParameter("vType", "springBus");
        springVehicle.run(context, "SpringParameters");


    }

    @GetMapping("/hello")
    public String hello() {
        Context context = new Context();
        context.addParameter("carType", "car");
        vehicle.run(context);
        return "hello";

    }


}
